<template>
  <div class="pages datails">
    <div class="content">
      <el-tabs v-model="activeName2" type="card" @tab-click="handleClick">
        <el-tab-pane label="基础信息" name="first">
          <div class="content-left">
            <ul class="rigth-ul">
              <li>姓名
                <span>{{tableDatas.name}} </span>
              </li>
              <li>手机号码
                <span>{{tableDatas.phone}}</span>
              </li>
              <li>性别
                <span v-if="tableDatas.gender==0">男</span>
                <span v-if="tableDatas.gender == 1">女</span>
              </li>
              <li>生日
                <span>{{tableDatas.birthday}}</span>
              </li>

              <li v-for="(items,index) in tableDatas.paramters" :key="index">{{items.name}}
                <span> {{items.fieldValue}}</span>
              </li>
              <!--  <li>与宝宝关系
                <span>{{tableDatas.babyRelation}}</span>
              </li> -->
              <li>宝妈状态
                <span v-if="tableDatas.currentState===1">怀孕中</span>
                <span v-if="tableDatas.currentState === 2">已有宝宝</span>
                <span v-if="tableDatas.currentState === 3">备孕中</span>
                <!-- (预产期 {{tableDatas.confinementDate}}) -->
              </li>
            </ul>
            <div class="box1" v-for="item in tableData" :key="item.value">
              <div class="boxbaby">
                {{item.name}}
              </div>
              <ul class="box1-ul">

                <li>小名：
                  <span>{{item.name}}</span>
                </li>
                <li>生日：
                  <span>{{item.birthday}}</span>
                </li>
                <li>性别：
                  <span v-if="item.gender==0">男</span>
                  <span v-if="item.gender == 1">女</span>
                </li>
                <li v-if="item.height!=''">身高：
                  <span>{{item.height}}(cm)</span>
                </li>
                <li v-if="item.weight!=''">体重：
                  <span>{{item.weight}}(kg)</span>
                </li>
              </ul>
            </div>

          </div>
        </el-tab-pane>
        <el-tab-pane label="营销信息" name="second">
          <div class="content-rigth">
            <div class="left-title">
              <ul class="left-ul">
                <li>会员等级:
                  <span> {{tableDatalx.levelName}}</span>
                </li>
                <li>累计积分:
                  <span> {{tableDatalx.integralTotal}}</span>
                </li>
                <li>余额:
                  <span> {{tableDatalx.currentAmount}}</span>
                </li>
                <li>消费次数:
                  <span> {{tableDatalx.consumeNum}}</span>
                </li>
                <li>剩余积分:
                  <span> {{tableDatalx.integral}}</span>
                </li>
                <li>加入日期:
                  <span> {{tableDatalx.createTime}}</span>
                </li>
                <li>所属门店:
                  <span> {{tableDatalx.storeName}}</span>
                </li>
              </ul>

              <div class="left-title_bottom">
                <!-- 2019.11.19日下午,经产品孙菁,java侯吕爽确认,积分换购接口为旧接口,无法使用,隐藏积分换购记录按钮 -->
                <!-- <el-button @click="dialogVisible = true,button1()">积分换购记录</el-button> -->
                <el-button @click="dialogVisiblej = true,button2()">商品寄存</el-button>
                <el-button @click="dialogVisiblec = true,button3()">寄存领取记录</el-button>
                <!-- <el-button @click="dialogVisiblecd = true,button4()">充值消费记录</el-button> -->
              </div>
            </div>
            <div class="left-list">
              <div class="list-1" v-for="item in tableData5.tickets" :key="item.value">
                <h1>¥{{item.ticketAmount}}</h1>
                <h2>[满元
                  <span>{{item.limitAmount}}</span>可用]</h2>
                <h3 v-if="item.isAll==0">部分商品</h3>
                <h3 v-if="item.isAll==1">全部商品</h3>
                <h3 v-if="item.isAll==2">全部服务</h3>
                <h3 v-if="item.isAll==3">部分服务</h3>
                <h4>有效期：{{item.startDate}}-{{item.endDate}}</h4>
              </div>
              <div class="list-1" v-for="items in tableData5.experienceTickets" :key="items.value">
                <h1>¥{{items.ticketPrice}}</h1>
                <h2>[{{items.ticketName}}]</h2>
                <!-- <h3>全品类可用</h3> -->
                <h4>有效期：{{items.startDate}}-{{items.endDate}}</h4>
              </div>
            </div>
          </div>

        </el-tab-pane>

      </el-tabs>
    </div>
    <!-- 换购 -->
    <el-dialog title="换购记录" class="addshopname" :close-on-click-modal="false" :close-on-press-escape="false" :visible.sync="dialogVisible" width="55%">
      <i class="el-icon-close icon" @click="huanicon"></i>
      <div class="tableMain">
        <el-table :data="tableData1" border style="width: 100%">
          <el-table-column prop="goodsName" label="商品名称" align="center"> </el-table-column>
          <el-table-column prop="goodsCount" label="数量" align="center"> </el-table-column>
          <el-table-column prop="unitName" label="单位" align="center"> </el-table-column>
          <el-table-column prop="integral" label="积分值" align="center"> </el-table-column>
          <el-table-column prop="createTime" label="换购时间" align="center" :formatter="formatTimes"></el-table-column>
        </el-table>
      </div>
      <div class="pageblock inut">
        <el-button size="small" class="topage" @click="toPage" type="primary">确定</el-button>
        <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[20,30]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="totalItems">
        </el-pagination>

      </div>

    </el-dialog>
    <!-- 商品寄存 -->
    <el-dialog title="寄存商品" class="addshopname" :close-on-click-modal="false" :close-on-press-escape="false" :visible.sync="dialogVisiblej" width="55%">
      <i class="el-icon-close icon" @click="shagpinicon"></i>
      <div class="tableMain">
        <el-table :data="tableData2" border style="width: 100%">
          <el-table-column prop="goodsName" label="商品名称" align="center"> </el-table-column>
          <!-- <el-table-column prop="goodsCode" label="编号" align="center"> </el-table-column> -->
          <!-- <el-table-column prop="brandName" label="品牌" align="center"> </el-table-column>
                <el-table-column prop="supplierName" label="供应商" align="center"> </el-table-column> -->
          <el-table-column prop="consignNum" label="数量" align="center"> </el-table-column>
          <el-table-column prop="unitName" label="单位" align="center"> </el-table-column>
          <el-table-column prop="createTime" label="寄存时间" align="center" :formatter="formatTimes"></el-table-column>
        </el-table>
      </div>
      <div class="pageblock inut">
        <el-button size="small" class="topage" @click="toPage" type="primary">确定</el-button>
        <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[20,30]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="totalItems1">
        </el-pagination>

      </div>
    </el-dialog>
    <!-- 寄存领取 -->
    <el-dialog title="寄存领取记录" class="addshopname" :close-on-click-modal="false" :close-on-press-escape="false" :visible.sync="dialogVisiblec" width="55%">
      <i class="el-icon-close icon" @click="jicunicon"></i>
      <div class="tableMain">
        <el-table :data="tableData3" border style="width: 100%">
          <el-table-column prop="goodsName" label="商品名称" align="center"> </el-table-column>
          <!-- <el-table-column prop="goodsCode" label="编号" align="center"> </el-table-column>
                <el-table-column prop="brandName" label="品牌" align="center"> </el-table-column>
                <el-table-column prop="supplierName" label="供应商" align="center"> </el-table-column> -->
          <el-table-column prop="receiveNum" label="领取数量" align="center"> </el-table-column>
          <el-table-column prop="unitName" label="单位" align="center"> </el-table-column>
          <el-table-column prop="createTime" label="领取时间" align="center" :formatter="formatTimes"></el-table-column>
        </el-table>
      </div>
      <div class="pageblock inut">
        <el-button size="small" class="topage" @click="toPage" type="primary">确定</el-button>
        <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[20,30]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="totalItems2">
        </el-pagination>

      </div>
    </el-dialog>
    <!-- 充值弹窗 -->
    <el-dialog title="充值消费记录" class="addshopname" :close-on-click-modal="false" :close-on-press-escape="false" :visible.sync="dialogVisiblecd" width="55%">
      <i class="el-icon-close icon" @click="chongicon"></i>
      <div class="tableMain">
        <el-table :data="tableData4" border style="width: 100%">
          <el-table-column prop="dealType" label="类型" align="center" :formatter="recharges"> </el-table-column>
          <el-table-column prop="amount" label="金额" align="center"> </el-table-column>
          <!-- <el-table-column prop="giftAmount" label="赠送金额" align="center"> </el-table-column> -->
          <el-table-column prop="endAmount" label="余额" align="center"> </el-table-column>
          <el-table-column prop="payType" label="支付方式" align="center" :formatter="paytype"> </el-table-column>
          <el-table-column prop="createTime" label="充值时间" align="center" :formatter="formatTimes"> </el-table-column>
          <!-- <el-table-column fixed="right" label="操作" align="center">
                  <template slot-scope="scope">
                    <el-button @click="handleClickchong(scope.row.memberId)" type="text" size="small" class="delete">撤销</el-button> -->
          <!-- <el-button type="text" @click="edit(scope.row.memberId)" size="small" >编辑</el-button> -->
          <!-- </template>
                </el-table-column> -->
        </el-table>
      </div>
      <div class="pageblock inut">
        <el-button size="small" class="topage" @click="toPage" type="primary">确定</el-button>
        <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[20,30]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="totalItems3">
        </el-pagination>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import util from "@/util";
import s from "@/util/state";
import {
  memberDetail,
  amountRecord,
  receiveRecord,
  storageRecord,
  redemptionRecord,
  marketInfo
} from "@/api";
export default {
  data() {
    return {
      birstday: "",
      vipid: "",
      activeName2: "first",
      total: 0,
      pageSize: 20,
      totalItems: 0,
      totalItems1: 0,
      totalItems2: 0,
      totalItems3: 0,
      currentPage: 1,
      dialogVisible: false,
      dialogVisiblej: false,
      dialogVisiblec: false,
      dialogVisiblecd: false,
      tableDatas: {},
      tableData1: [],
      tableData2: [],
      tableData3: [],
      tableData4: [],
      tableData5: [],
      tableDatalx: {},
      tableData: []
    };
  },
  mounted() {
    this.listq();
    this.listyx();
  },
  methods: {
    formatTimes: function(row) {
      return util.foryear(parseInt(row.createTime));
    },
    paytype: s.paytype,
    recharges: s.recharges,
    sex: s.sex,
    timestamp: util.timestamp,
    button1() {
      this.list(this.pageSize, 1);
    },
    button2() {
      this.list1(this.pageSize, 1);
    },
    button3() {
      this.list2(this.pageSize, 1);
    },
    button4() {
      this.list3(this.pageSize, 1);
    },
    handleClick(tab, event) {
      //   console.log(tab, event)
    },
    list3(pageSize, pageNum) {
      //充值消费记录
      let ids = util.getQuery("id");
      let data = {
        id: ids,
        pageSize: pageSize,
        pageNum: pageNum
      };
      amountRecord(data).then(res => {
        //  请求成功后的函数-
        this.tableData4 = res.data.list;
        this.totalItems3 = parseInt(res.data.totalRecord);
      });
    },
    list2(pageSize, pageNum) {
      //寄存领取记录
      let ids = util.getQuery("id");
      let data = {
        id: ids,
        pageSize: pageSize,
        pageNum: pageNum
      };
      receiveRecord(data).then(res => {
        //  请求成功后的函数-
        this.tableData3 = res.data.list;
        this.totalItems2 = parseInt(res.data.totalRecord);
      });
    },
    list1(pageSize, pageNum) {
      //商品寄存记录
      let ids = util.getQuery("id");
      let data = {
        memberCompanyId: ids,
        pageSize: pageSize,
        pageNum: pageNum
      };
      storageRecord(data).then(res => {
        //  请求成功后的函数-
        this.tableData2 = res.data.list;
        this.totalItems1 = parseInt(res.data.totalRecord);
      });
    },
    list(pageSize, pageNum) {
      //会员换购记录
      let ids = util.getQuery("id");
      let data = {
        id: ids,
        pageSize: pageSize,
        pageNum: pageNum
      };
      redemptionRecord(data).then(res => {
        //  请求成功后的函数-
        this.tableData1 = res.data.list;
        this.totalItems = parseInt(res.data.totalRecord);
      });
    },
    listq() {
      //查询会员信息
      let data = {
        id: util.getQuery("id"),
        shopId: util.getQuery("storeId"),
        compnanyId: util.getQuery("compnanyId")
      };
      memberDetail(data).then(res => {
        this.tableData = res.data.babys;
        this.tableDatas = res.data;
        if (this.tableData != null) {
          for (var i = 0; i < this.tableData.length; i++) {
            var timestamp4 = new Date(this.tableData[i].birthday);
            this.tableData[i].birthday =
              timestamp4.toLocaleDateString().replace(/\//g, "-") +
              " " +
              timestamp4.toTimeString().substr(0, 0);
          }
        }
        if (this.tableDatas.birthday != null) {
          var timestamp5 = new Date(this.tableDatas.birthday);
          this.tableDatas.birthday =
            timestamp5.toLocaleDateString().replace(/\//g, "-") +
            " " +
            timestamp5.toTimeString().substr(0, 0);
        }
      });
    },
    listyx() {
      //查询营销信息
      let ids = util.getQuery("id");
      let data = {
        memberCompanyId: ids
      };
      marketInfo(data).then(res => {
        //  请求成功后的函数-
        this.tableDatalx = res.data;
        //转时间戳
        var timestamp4 = new Date(this.tableDatalx.createTime);
        this.tableDatalx.createTime =
          timestamp4.toLocaleDateString().replace(/\//g, "-") +
          " " +
          timestamp4.toTimeString().substr(0, 0);
      });
    },
    jcsp() {
      this.$router.push("./jcsp?&id" + this.vipid);
    },
    jclq() {
      this.$router.push("./jclq?&id" + this.vipid);
    },
    handleSizeChange(val) {
      this.pageSize = val;
      this.list(this.pageSize, this.currentPage);
      this.list1(this.pageSize, this.currentPage);
      this.list2(this.pageSize, this.currentPage);
      this.list3(this.pageSize, this.currentPage);
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      this.list(this.pageSize, this.currentPage);
      this.list1(this.pageSize, this.currentPage);
      this.list2(this.pageSize, this.currentPage);
      this.list3(this.pageSize, this.currentPage);
    },
    toPage() {
      this.list(this.pageSize, this.currentPage);
      this.list1(this.pageSize, this.currentPage);
      this.list2(this.pageSize, this.currentPage);
      this.list3(this.pageSize, this.currentPage);
    },
    // 换购弹窗
    huanicon() {
      this.dialogVisible = false;
    },
    // 商品弹窗
    shagpinicon() {
      this.dialogVisiblej = false;
    },
    // 寄存领取记录
    jicunicon() {
      this.dialogVisiblec = false;
    },
    // 充值按钮
    chongicon() {
      this.dialogVisiblecd = false;
    },
    // 撤销
    handleClickchong() {
      this.$confirm("确定要撤销此次充值吗？?", "提示", {
        center: true,
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        closeOnClickModal: false,
        closeOnPressEscape: false
      })
        .then(() => {
          rows.splice(index, 1);
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "撤销此次充值"
          });
        });
    }
  }
};
</script>
<style>
.content .el-tabs__nav-scroll {
  width: 450px;
  margin: 0 auto;
}
.addshopname .inut .el-input {
  width: 100px;
}
</style>
<style scoped>
.box2 {
  width: 960px;
  height: 380px;
  float: left;
  background: #f2f2f2;
  margin-top: 16px;
}
.box2-bz {
  color: #000;
  font-weight: bold;
  font-size: 14px;
  width: 620px;
  height: 40px;
  line-height: 40px;
  margin-top: 20px;
  margin-left: 10px;
  text-indent: 60px;
  border-top: 1px dashed #bcbcbc;
}

.box2-bz span {
  color: #757575;
}
.box2-ul1 {
  color: #000;
  font-weight: bold;
  font-size: 13px;
  margin-top: 14px;
  width: 620px;
  height: 30px;
  line-height: 30px;
  margin-left: 10px;
  border-bottom: 1px solid #bcbcbc;
}
.box2-ul1 li {
  margin-left: 50px;
  float: left;
}
.box2-ul1 .li1 {
  margin-left: 10px;
}
.box2-ul2 {
  margin-left: 35px;
  margin-top: 10px;
}
.box2-ul2 li {
  color: #000;
  font-weight: bold;
  font-size: 13px;
  line-height: 28px;
}
.box2-ul2 li span {
  color: #6b6b6b;
}
.box2-right {
  width: 659px;
  height: 380px;
  float: right;
}
.box2-left {
  width: 220px;
  height: 380px;
  float: left;
  border-right: 1px solid #bcbcbc;
}
.box2-ul {
  margin: 25px;
  color: #000;
  font-weight: bold;
  font-size: 13px;
}
.box2-ul li {
  line-height: 26px;
}
.box2-ul li span {
  margin-left: 10px;
}

.box2 h6 {
  color: #169bd5;
  font-size: 14px;
  margin-top: 16px;
  margin-left: 66px;
}
.box1 {
  width: 960px;
  height: 160px;
  background: #f2f2f2;
  overflow: hidden;
  padding: 15px;
  box-sizing: border-box;
  margin-top: 10px;
}
.box1 .boxbaby {
  width: 200px;
  float: left;
  line-height: 116px;
  text-align: center;
  color: #444;
  font-size: 16px;
}
.box1-ul {
  float: left;
  margin-top: 4px;
  position: relative;
  width: 500px;
}
.box1-ul li {
  line-height: 30px;
  font-size: 14px;
}
.box1-ul li:nth-child(5) {
  position: absolute;
  bottom: 1px;
  left: 290px;
}
.box1-ul span {
  margin-left: 10px;
}
.box1 h6 {
  color: #169bd5;
  font-size: 14px;
  margin-top: 16px;
  margin-left: 66px;
}
.content {
  width: 100%;
  height: 1000px;
  margin-top: 15px;
}
.cont-ul {
  width: 301px;
  height: 40px;
  margin-left: 260px;
  border: 1px solid #e4e7ed;
  margin-top: 18px;
}
.cont-ul li {
  width: 150px;
  line-height: 40px;
  font-size: 16px;
  float: left;
  color: #303133;
  text-align: center;
}
.cont-ul .li1 {
  color: #409eff;
  border-right: 1px solid #e4e7ed;
}
.content-left {
  width: 60%;
  float: left;
  margin-left: 11%;
}
.left-title {
  width: 100%;
  height: 280px;
  border-bottom: 1px dashed #aeaeae;
  box-sizing: border-box;
  overflow: hidden;
}
.left-title .left-ul {
  width: 80%;
  margin: 0 auto;
  margin-top: 20px;
  position: relative;
}
.left-title .left-ul li {
  font-size: 14px;
  color: #444;
  line-height: 35px;
}
.left-title .left-ul li:nth-child(3) {
  position: absolute;
  top: 15px;
  left: 330px;
}
.left-title .left-ul li:nth-child(5) {
  position: absolute;
  top: 75px;
  left: 330px;
}
.left-title .left-title_bottom {
  width: 550px;
  margin: 0 auto;
  margin-top: 15px;
}
.left-title .left-ul li span {
  margin-left: 20px;
}
.left-button1 {
  width: 96px;
  height: 36px;
  border-radius: 8px;
  border: none;
  position: absolute;
  bottom: 10px;
  left: 488px;
}
.left-button2 {
  width: 96px;
  height: 36px;
  border-radius: 8px;
  border: none;
  position: absolute;
  bottom: 10px;
  left: 642px;
}
.left-button3 {
  width: 120px;
  height: 36px;
  border-radius: 8px;
  border: none;
  position: absolute;
  bottom: 10px;
  left: 788px;
}
.list-1 {
  width: 600px;
  height: 100px;
  background: #f2f2f2;
  margin: 10px auto;
  border-radius: 10px;
  position: relative;
}
.list-1 h1 {
  font-size: 24px;
  position: absolute;
  font-weight: bolder;
  top: -13px;
  left: 35px;
}
.list-1 h2 {
  font-size: 14px;
  position: absolute;
  bottom: 8px;
  left: 35px;
  color: #444;
}
.list-1 h3 {
  font-size: 13px;
  position: absolute;
  top: 4px;
  left: 246px;
  color: #868686;
}
.list-1 h4 {
  font-size: 13px;
  position: absolute;
  bottom: 8px;
  left: 250px;
  color: #868686;
}
.content-rigth {
  float: left;
  width: 60%;
  height: 640px;
  /*  border: 1px solid #c9c9c9;*/
  margin-right: 10px;
  margin-top: 10px;
  border-radius: 10px;
  margin-left: 11%;
}
.rigth-ul {
  width: 100px;
  padding: 20px;
  font-size: 14px;
  color: #444;
}
.rigth-ul li {
  line-height: 30px;
  text-align: right;
  width: 100px;
  position: relative;
}
.rigth-ul li span {
  width: 220px;
  text-align: left;
  position: absolute;
  right: -260px;
}
.rigth-ul2 {
  width: 500px;
  height: 186px;
  float: left;
  margin-top: 20px;
}
.rigth-ul2 li {
  line-height: 30px;
  text-indent: 30px;
  width: 100%;
  float: left;
}
.box-ul {
  position: absolute;
  top: 10px;
  left: 130px;
}
.box-ul li {
  line-height: 22px;
}
.box-ul li span {
  margin-left: 20px;
}
.box2-right {
  width: 659px;
  height: 380px;
  float: right;
}
.form {
  margin: 10px auto;
  width: 980px;
}
</style>
